/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_LOGR")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbLogr.findAll", query = "SELECT a FROM AmTbLogr a"),
    @NamedQuery(name = "AmTbLogr.findByCdCep", query = "SELECT a FROM AmTbLogr a WHERE a.cdCep = :cdCep"),
    @NamedQuery(name = "AmTbLogr.findByNmLogr", query = "SELECT a FROM AmTbLogr a WHERE a.nmLogr = :nmLogr"),
    @NamedQuery(name = "AmTbLogr.findByNrLogrInic", query = "SELECT a FROM AmTbLogr a WHERE a.nrLogrInic = :nrLogrInic"),
    @NamedQuery(name = "AmTbLogr.findByNrLogrTerm", query = "SELECT a FROM AmTbLogr a WHERE a.nrLogrTerm = :nrLogrTerm")})
public class AmTbLogr implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_CEP")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_LOGR")
    @SequenceGenerator(name="seq_AM_TB_LOGR", sequenceName = "seq_AM_TB_LOGR")
    private Integer cdCep;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 70)
    @Column(name = "NM_LOGR")
    private String nmLogr;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NR_LOGR_INIC")
    private int nrLogrInic;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NR_LOGR_TERM")
    private int nrLogrTerm;
    @JoinColumn(name = "CD_BAIR", referencedColumnName = "CD_BAIR")
    @ManyToOne(optional = false)
    private AmTbBair cdBair;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdCep")
    private Collection<AmTbLocaAtenMedi> amTbLocaAtenMediCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdCep")
    private Collection<AmTbPaci> amTbPaciCollection;

    public AmTbLogr() {
    }

    public AmTbLogr(Integer cdCep) {
        this.cdCep = cdCep;
    }

    public AmTbLogr(Integer cdCep, String nmLogr, int nrLogrInic, int nrLogrTerm) {
        this.cdCep = cdCep;
        this.nmLogr = nmLogr;
        this.nrLogrInic = nrLogrInic;
        this.nrLogrTerm = nrLogrTerm;
    }

    public Integer getCdCep() {
        return cdCep;
    }

    public void setCdCep(Integer cdCep) {
        this.cdCep = cdCep;
    }

    public String getNmLogr() {
        return nmLogr;
    }

    public void setNmLogr(String nmLogr) {
        this.nmLogr = nmLogr;
    }

    public int getNrLogrInic() {
        return nrLogrInic;
    }

    public void setNrLogrInic(int nrLogrInic) {
        this.nrLogrInic = nrLogrInic;
    }

    public int getNrLogrTerm() {
        return nrLogrTerm;
    }

    public void setNrLogrTerm(int nrLogrTerm) {
        this.nrLogrTerm = nrLogrTerm;
    }

    public AmTbBair getCdBair() {
        return cdBair;
    }

    public void setCdBair(AmTbBair cdBair) {
        this.cdBair = cdBair;
    }

    @XmlTransient
    public Collection<AmTbLocaAtenMedi> getAmTbLocaAtenMediCollection() {
        return amTbLocaAtenMediCollection;
    }

    public void setAmTbLocaAtenMediCollection(Collection<AmTbLocaAtenMedi> amTbLocaAtenMediCollection) {
        this.amTbLocaAtenMediCollection = amTbLocaAtenMediCollection;
    }

    @XmlTransient
    public Collection<AmTbPaci> getAmTbPaciCollection() {
        return amTbPaciCollection;
    }

    public void setAmTbPaciCollection(Collection<AmTbPaci> amTbPaciCollection) {
        this.amTbPaciCollection = amTbPaciCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdCep != null ? cdCep.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbLogr)) {
            return false;
        }
        AmTbLogr other = (AmTbLogr) object;
        if ((this.cdCep == null && other.cdCep != null) || (this.cdCep != null && !this.cdCep.equals(other.cdCep))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbLogr[ cdCep=" + cdCep + " ]";
    }
    
}
